//
//  DMInFoViewCell.m
//  DMGME
//
//  Created by MC on 15/10/24.
//  Copyright © 2015年 GYP. All rights reserved.
//

#import "DMInFoViewCell.h"
#import "DMInfoModel.h"


@implementation DMInFoViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//                [self setValuesForKeysWithDictionary:dic];
        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
        _img = img;
    
        [self.contentView addSubview:img];
    /*
     @property (weak, nonatomic)  UILabel *title;
     @property (weak, nonatomic)  UILabel *textLabel1;
     
     @property (weak, nonatomic)  UILabel *timeLabel;
     */
        
        UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(65, 10, KWidth-130, 21)];
        title.font = [UIFont systemFontOfSize:16];
        _title = title;
        title.textColor = [UIColor colorWithRed: 68/255.0  green: 68/255.0  blue: 68/255.0  alpha: 1];
        [self.contentView addSubview:title];
        
        
        
        UILabel *textLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(65, CGRectGetMaxY(title.frame)+3, KWidth-130, 21)];
        _textLabel1 = textLabel1;
        textLabel1.font = [UIFont systemFontOfSize:14];
        textLabel1.textColor = [UIColor colorWithRed: 68/255.0  green: 68/255.0  blue: 68/255.0  alpha: 1];
        [self.contentView addSubview:textLabel1];
        UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, CGRectGetMaxY(textLabel1.frame)-3, KWidth-130, 21)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        timeLabel.textColor = [UIColor lightGrayColor];
        _timeLabel = timeLabel;
        timeLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:timeLabel];
    }
    self.selectionStyle = NO;
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}
-(void)setModel:(DMInfoModel *)model
{
    _model = model;
  
    /*
     @property (nonatomic,copy) NSString *id;
     @property (nonatomic,copy) NSString *content;
     @property (nonatomic,copy) NSString *create_time;
     @property (nonatomic,copy) NSString *title;
     */
    
    _img.image = [UIImage imageNamed:@"icon"];
    _title.text = model.title;
    _textLabel1.text = model.content;
    NSString *str = [ [self timeStamaps:model.create_time] substringWithRange:NSMakeRange(0, 16)];
    _timeLabel.text = str;
    
}
-(NSString *)timeStamaps:(NSString *)str
{
    //时间戳转化为时间字符串
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:[str longLongValue]];
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *string = [formatter stringFromDate:date];
    //    NSLog(@"date1:%@",str);
    return string;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
